package com.tanhua.gateway.test;

import cn.hutool.core.collection.CollUtil;
import com.easemob.im.server.EMProperties;
import com.easemob.im.server.EMService;
import com.easemob.im.server.model.EMTextMessage;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;

import java.util.Set;

@Slf4j
public class HuanXinTemplate {

    private EMService service;

    @Before
    public void init() {
        EMProperties emProperties = EMProperties.builder()
                .setAppkey("1159220315091201#tanhua")
                .setClientId("YXA65vuWtiMrSaORK-ggknAFcg")
                .setClientSecret("YXA6pzlkTuf1ZY5YBkSqVAJ6DOdtWZU")
                .build();
        service = new EMService(emProperties);
    }

    @Test
    public void test(){
        // 注册用户
//        service.user().create("user002","123456").block();
        // 添加联系人(加好友)
//        service.contact().add("user001","user002").block();
        // 发送消息
        Set<String> set = CollUtil.newHashSet("usre002");
        service.message().send(
                "user001",
                "users",set,new EMTextMessage().text("java"),
                null).block();
    }
}